<template>
  <div>
    <XiaomiPhone />
      <div class="nav">
        <a href="#/Xiaomi" :class="{ 'slide-in': isXiaomiActive }">推荐</a>
        <a href="#/Redmi" :class="{ 'slide-in': isRedmiActive }">手机</a>
        <a href="#/Tv" :class="{ 'slide-in': isTvActive }">电视</a>
        <a href="#/Tv" :class="{ 'slide-in': isTvActive }">我的</a>

      </div>
      <div>
        <router-view></router-view>
      </div>
  </div>

</template>

<script>
export default {
  data() {
    return {
      isXiaomiActive: false,
      isRedmiActive: false,
      isTvActive: false,
    };
  },
  methods: {
    setActive(navItem) {
      this.isXiaomiActive = navItem === 'Xiaomi' ? true : false;
      this.isRedmiActive = navItem === 'Redmi' ? true : false;
      this.isTvActive = navItem === 'Tv' ? true : false;
    }
  },
  mounted() {
    // 假设默认激活推荐
    this.setActive('Xiaomi');
  }
};
</script>
<style>
/* App.vue 或者你的样式文件 */
.nav {
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: white;
  height: 60px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.nav a {
  color: rgb(0, 0, 0);
  text-decoration: none;
  font-size: 16px;
  font-weight: bold;
  transition: color 0.3s ease-in-out;
}

.nav a:hover {
  color: #ff7e5f;
  /* 鼠标悬停时的颜色变化 */
}

@keyframes slideIn {
  from {
    transform: translateX(-100%);
  }

  to {
    transform: translateX(0);
  }
}

/* 动画类 */
.slide-in {
  animation: slideIn 0.5s ease-in-out forwards;
}
</style>
